package com.whc.vo;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
 * @author 韦红材
 * @ClassName SecurityUser
 * @data 2024/12/22 17:42
 * @Version V1.0
 **/
@Data
//@AllArgsConstructor
@NoArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public class SecurityUser implements Serializable {
    private static final long serialVersionUID = 1L;


    private List<String> authorities;

    private String password;

    private String username;

    private boolean accountNonExpired;

    public boolean accountNonLocked;

    public boolean credentialsNonExpired;

    public boolean enabled;

    public SecurityUser(Collection<? extends GrantedAuthority> authorities, String password, String username, boolean accountNonExpired, boolean accountNonLocked, boolean credentialsNonExpired, boolean enabled) {
        this.authorities =new  ArrayList<>();
        for(GrantedAuthority g:authorities){
            this.authorities.add(g.getAuthority());
        }
        this.password = password;
        this.username = username;
        this.accountNonExpired = accountNonExpired;
        this.accountNonLocked = accountNonLocked;
        this.credentialsNonExpired = credentialsNonExpired;
        this.enabled = enabled;
    }
}
